package main.java.com.fronted.css;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class FrameDemo3 extends JFrame {
    public void createFrame(){
        JFrame frame = new JFrame("Virtual Airlines Mataverse");
        frame.setLayout(null);
        frame.setResizable(false);
        JPanel jp = new JPanel();
        jp.setLayout(null);
        ImageIcon bg=new ImageIcon("src/main/resources/3.jpg");
        JLabel label=new JLabel(bg);
        label.setSize(bg.getIconWidth(),bg.getIconHeight());
        frame.getLayeredPane().add(label,new Integer(Integer.MIN_VALUE));

        JLabel l1 = new JLabel("Virtual Airlines Mataverse");
        l1.setForeground(Color.white);
        l1.setFont(new Font("Times New Roman", Font.BOLD, 50));
        l1.setBounds(130,200,800,50);
        frame.add(l1);

        JLabel l2 = new JLabel("Welcome to our software on a virtual Airlines Mataverse lab and virtual Game!");
        l2.setForeground(Color.white);
        l2.setFont(new Font("Times New Roman", Font.BOLD, 20));
        l2.setBounds(60,250,800,50);
        frame.add(l2);

        JLabel l3 = new JLabel("Designed by XuHui Li, NPU");
        l3.setForeground(Color.white);
        l3.setFont(new Font("Times New Roman", Font.BOLD,20));
        l3.setBounds(250,300,800,50);
        frame.add(l3);

        JPanel pan=(JPanel)frame.getContentPane();
        pan.setOpaque(false);

        JButton jb1 = new JButton("Click to start our Universe");//设置按钮
        jb1.setLayout(null);
        jb1.setBounds(200,350,350,30);
        frame.add(jb1);
        //事件监听器接口
        ReListener re = new ReListener();
        jb1.addActionListener(re);



        Font font1 = new Font("Georgia", Font.BOLD, 20);
        jb1.setFont(font1);
        jb1.setForeground(Color.RED);
        jb1.setBackground(Color.cyan);

        // 设置窗口的位置
        frame.setVisible(true);
        frame.setSize(780, 520);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }



    public class ReListener implements ActionListener {
        @Override
        public void actionPerformed(ActionEvent e) {
            main_page.create_page2();
        }
    }


    public class LoginListener implements ActionListener {

        private javax.swing.JButton enter1;

        public LoginListener(javax.swing.JButton enter1) {
            this.enter1 = enter1;//获取登录界面
        }

        public void actionPerformed(ActionEvent e) {
            //用户名密码判断
            if (enter1.getText().equals("user") && enter1.getText().equals("root")) {
                //设置弹框
                JOptionPane.showMessageDialog(null, "登陆成功", "成功", 1);
                Login.createShow();
                enter1.setVisible(false);
            } else if (!(enter1.getText().equals("1") && enter1.getText().equals("1"))) {
                JOptionPane.showMessageDialog(null, "登录名或密码错误", "失败", 0);
            }

        }
    }

    public static void main(String[] args) {
        new FrameDemo3().createFrame();
    }

}
